FROM adoptopenjdk/openjdk11-openj9

MAINTAINER Pimax

ARG PORT
ARG AUTH_HOST
ARG AUTH_PORT
ARG SOURCE_JAR
ARG JAR_FILE
ARG CONFIG_HOST
ARG CONFIG_PORT
ARG DISCOVERY_HOST
ARG DISCOVERY_PORT
ARG CONFIG_NAMESPACE
ARG DOCKERIZE_TIMEOUT
ARG JAVA_OPTS
ARG PROFILES


ADD dockerize dockerize
RUN chmod 777 dockerize

ENV SPRING_OUTPUT_ANSI_ENABLED=ALWAYS \
    JAVA_OPTS=$JAVA_OPTS \
    CONFIG_HOST=$CONFIG_HOST \
    CONFIG_PORT=$CONFIG_PORT \
    DISCOVERY_HOST=$DISCOVERY_HOST \
    DISCOVERY_PORT=$DISCOVERY_PORT \
    CONFIG_NAMESPACE=$CONFIG_NAMESPACE \
    DOCKERIZE_TIMEOUT=$DOCKERIZE_TIMEOUT \
    PORT=$PORT \
    AUTH_HOST=$AUTH_HOST \
    AUTH_PORT=$AUTH_PORT \
    SOURCE_JAR=$SOURCE_JAR \
    JAR_FILE=$JAR_FILE

ADD $SOURCE_JAR $JAR_FILE

ENTRYPOINT ["sh", "-c", "./dockerize -version && java $JAVA_OPTS  -Dspring.profiles.active=$PROFILES -jar $JAR_FILE" ]

EXPOSE $PORT